package com.laicunba.util;

import java.net.HttpURLConnection;
import java.net.URL;

import org.apache.commons.io.IOUtils;

public class IpUtil {

	public static String get(String ip) {
		HttpURLConnection conn = null;
		try {
			URL url = new URL("http://int.dpool.sina.com.cn/iplookup/iplookup.php?ip=" + ip);
			conn = (HttpURLConnection) url.openConnection();
			String place = IOUtils.toString(conn.getInputStream(), "gbk");
			return place.replaceAll("[0-9\\-\t]", "").replace(" ", "");
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			conn.disconnect();
		}
		return null;
	}

}
